package Dungeon;

import java.util.ArrayList;

import squarePackage.PlainSquare;
import squarePackage.SquareImp;
import squarePackage.TeleportTransparantSquare;
import Enumerations.Directions;
import Exceptions.IllegalDimensionException;
import Exceptions.IllegalDungeonException;

public class CompositeDungeonUsage {

	/**
	 * @param args
	 * @throws IllegalDimensionException 
	 */
	public static void main(String[] args) throws IllegalDimensionException {
		
		System.out.println("Here we create 1 composite dungeon and add 2 subdungeons");
		CompositeDungeon<SquareImp> composite = new CompositeDungeon<SquareImp>(1000, 1000, 1000);
		
		Level<SquareImp> level1 = new Level<SquareImp>(10,10,10,0);
		Shaft<SquareImp> shaft = new Shaft<SquareImp>(10, 10, 10, 0, 1, -5);
		
		
		
		PlainSquare square1 = new PlainSquare();
		PlainSquare square2 = new PlainSquare();
		PlainSquare square3 = new PlainSquare();
		PlainSquare square4 = new PlainSquare();
		PlainSquare square5 = new PlainSquare();
		PlainSquare square6 = new PlainSquare();
		PlainSquare square7 = new PlainSquare();
		
		ArrayList<SquareImp> destinationlist = new ArrayList<SquareImp>();
		destinationlist.add(square7);
		
		PlainSquare square8 = new PlainSquare();
		PlainSquare square9 = new PlainSquare();
		PlainSquare square10 = new PlainSquare();
		TeleportTransparantSquare transparantSquare = new TeleportTransparantSquare(destinationlist);
		
		
		square1.setMaterial(false);
		square2.setMaterial(false);
		square3.setMaterial(false);
		square4.setMaterial(false);
		square5.setMaterial(false);
		square6.setMaterial(false);
		square7.setMaterial(false);
		square8.setMaterial(false);
		square9.setMaterial(false);
		square10.setMaterial(false);
		transparantSquare.setMaterial(false);
		
		//shaft vakjes niet op 0 1 0 toevoegen
		
		level1.addSquareToDungeon(1, 0, 0, square1);
		level1.addSquareToDungeon(2, 0, 0, square2);
		level1.addSquareToDungeon(3, 0, 0, square3);
		level1.addSquareToDungeon(4, 0, 0, square4);
		level1.addSquareToDungeon(5	, 0, 0, square5);
		level1.addSquareToDungeon(6, 0, 0, square6);
		level1.addSquareToDungeon(7, 0, 0, square7);
		
		shaft.addSquareToDungeon(0, 1, 1, square8);
		shaft.addSquareToDungeon(0, 1, 2, square9);
		shaft.addSquareToDungeon(0, 1, 3, square10);
		shaft.addSquareToDungeon(0, 1, 4, transparantSquare);
		
		
		//een level met origin 0 1 0  in composite, en eigen vakjes 1 00 , 2 0 0 ,3 0 0, 4 0 0, 500
		// 	tov composite is dit dus 1 1 0 , 2 1 0 , 3 1 0 , 4 1 0 , 5 1 0 
		//een shaft met origin 3 0 0 in composite en dan eigen vakjes
		//	eerste vakje is op 0 1 1, tov composite is dit 3 1 1 , dus level en shaft raken elkar op 3 1 1 en 3 1 0 
		
		System.out.println("We add a level at coordinate  0 1 0 in the composite dungeon");
		System.out.println("Next we add a shaft at coordinate 3 0 0 in the composite dungeon");
		System.out.println("the subdungeons are positioned so that a certain square of the level shares a border with the bottom square of the shaft");
		
		
		try {
			composite.addDungeonToCompositeDungeon(0, 1, 0, level1);
			System.out.println();
			System.out.println("To the level we added 7 plainsquares starting at coordinate 1 0 0   and goes to 7 0 0 ");
			System.out.println("the square coordinates in the level are printed in the next line");
			System.out.println(level1.getAllCoordinatesInDungeon());
			System.out.println("If the translate it to coordinates in the composite dungeon, the coordinates look like the next line");
			System.out.println(composite.getAllCoordinatesInDungeon());
			composite.addDungeonToCompositeDungeon(3, 0, 0, shaft);
			System.out.println();
			System.out.println("We also add 4 squares to the shaft, one of them is a transparant square with teleportation capacities");
			System.out.println("The square coordinates in the shaft are printed in the next line");
			System.out.println(shaft.getAllCoordinatesInDungeon());
			
			System.out.println("If the translate it to coordinates in the composite dungeon, the coordinates look like the next line");
			System.out.println(composite.getAllCoordinatesInDungeon());
		} catch (IllegalDungeonException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		System.out.println();
		System.out.println();
		System.out.println("None of the square have specific borders, all of them have a floor");
		System.out.println("Only the transparant square has a border in north direction");
		System.out.println("So normally all the squares in the shaft are isolated, only the 2 top ones (a plainsquare and a transparantsquare, they are in the same space");
		System.out.println();
		System.out.println("Here we print the spaces ");
		System.out.println("1 space with 7 squares of the level (they have no border)");
		System.out.println("1 space with 2 squares of the shaft(also no border)");
		for(ArrayList<SquareImp> list : composite.getListOfSpaces()){
			System.out.println(list);
		}
		System.out.println();
		System.out.println();

		System.out.println("Here we print a list of the destination squares of the teleportsquare");
		System.out.println("And beneath we print again the space in the level");
		System.out.println(transparantSquare.getDestinationList());
		System.out.println(composite.getSpaceOfSquare(square7));
		System.out.println("So it is clear that the teleportsquare has a destination in the other subdungeon");
		System.out.println();
		System.out.println();
		
		System.out.println("Is square 1 reachable starting from the teleportsquare ? : " + composite.isReachable(transparantSquare, square1));
		System.out.println("Is square 1 reachable starting from the other square in the space of teleport teleportsquare? :  " + composite.isReachable(square10, square1));
		System.out.println("Is square 5 reachable starting from the other square in the space of teleport teleportsquare ? : " + composite.isReachable(square10, square5));
		
		
		

	}

}
